package com.restaurant.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.restaurant.domain.Modifiremaster;

public class ModifireFormValidator implements Validator{

	@Override
	public boolean supports(Class<?> arg0) {
		return Modifiremaster.class.isAssignableFrom(arg0);
	}

	@Override
	public void validate(Object arg0, Errors errors) {
		Modifiremaster modifiremaster = (Modifiremaster) arg0;
		
		if(modifiremaster.getModifirename().trim().length()<=0)
			ValidationUtils.rejectIfEmptyOrWhitespace(errors, "modifirename", "modifirename.error");
		
		if((modifiremaster.getPrice()+"").length()<=0)
			ValidationUtils.rejectIfEmptyOrWhitespace(errors, "price", "price.error");
		
	}

}
